home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / IBM VisualAge for Java Enterprise v4.0 Retail / ivj40 / setup / IDE.Cab / F77450_VAJava2StatusLineUI.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-04-25  |  3.6 KB  |  108 lines

  1. package com.ibm.ivb.jface.vajava2;
  2.  
  3. import com.ibm.ivb.jface.parts.CellLayout;
  4. import com.ibm.ivb.jface.parts.StatusLine;
  5. import com.ibm.ivb.jface.parts.TaskIndicator;
  6. import com.ibm.ivb.jface.plaf.StatusLineUI;
  7. import java.awt.Color;
  8. import java.awt.Component;
  9. import java.awt.Container;
  10. import java.awt.Dimension;
  11. import java.awt.Graphics;
  12. import java.awt.LayoutManager;
  13. import java.util.Vector;
  14. import javax.swing.JComponent;
  15. import javax.swing.JLabel;
  16. import javax.swing.border.Border;
  17. import javax.swing.border.CompoundBorder;
  18. import javax.swing.border.EmptyBorder;
  19. import javax.swing.plaf.ComponentUI;
  20.  
  21. public class VAJava2StatusLineUI extends StatusLineUI {
  22.    private static final String kCBIBMCopyright = "(c) Copyright IBM Corporation 1998";
  23.    JLabel message;
  24.    JLabel icon;
  25.    TaskIndicator task;
  26.    Color savedBg;
  27.    Border border;
  28.  
  29.    public static ComponentUI createUI(JComponent var0) {
  30.       return new VAJava2StatusLineUI();
  31.    }
  32.  
  33.    public TaskIndicator getTaskIndicator() {
  34.       return this.task;
  35.    }
  36.  
  37.    public void installUI(JComponent var1) {
  38.       StatusLine var2 = (StatusLine)var1;
  39.       CellLayout var3 = new CellLayout(var2);
  40.       ((Container)var2).removeAll();
  41.       this.border = new ClientBorder();
  42.       ((JComponent)var2).setBorder(this.border);
  43.       StatusBorder var4 = new StatusBorder();
  44.       CompoundBorder var5 = new CompoundBorder(var4, new EmptyBorder(3, 5, 3, 5));
  45.       this.savedBg = ((Component)var2).getBackground();
  46.       ((JComponent)var2).setBackground(VAJava2LookAndFeel.getDark1());
  47.       this.icon = new JLabel();
  48.       this.icon.setVerticalAlignment(0);
  49.       this.icon.setHorizontalAlignment(0);
  50.       this.icon.setBorder(var5);
  51.       this.message = new JLabel(" ");
  52.       this.message.setBorder(var5);
  53.       this.task = new TaskIndicator();
  54.       this.task.setPreferredSize(new Dimension(100, this.task.getPreferredSize().height));
  55.       this.task.setBorder(new CompoundBorder(var4, new EmptyBorder(2, 2, 2, 2)));
  56.       var3.setFill(3);
  57.       var3.setWeight(0, 1);
  58.       var3.addToCell(this.icon, 0, 0);
  59.       var3.addToCell(this.task, 1, 0);
  60.       var3.setFill(1);
  61.       var3.setWeight(1, 1);
  62.       var3.addToCell(this.message, 2, 0);
  63.       Vector var6 = var2.getUserComponents();
  64.       if (var6 != null) {
  65.          var3.setFill(1);
  66.          var3.setWeight(0, 1);
  67.  
  68.          for(int var7 = 0; var7 < var6.size(); ++var7) {
  69.             var3.addToCell((Component)var6.elementAt(var7), var7 + 1, 0);
  70.          }
  71.       }
  72.  
  73.    }
  74.  
  75.    public void paint(Graphics var1, JComponent var2) {
  76.       Dimension var3 = ((Component)var2).getSize();
  77.       var1.setColor(((Component)var2).getBackground());
  78.       var1.fillRect(0, 0, var3.width, var3.height);
  79.    }
  80.  
  81.    public void uninstallUI(JComponent var1) {
  82.       StatusLine var2 = (StatusLine)var1;
  83.       ((Container)var2).setLayout((LayoutManager)null);
  84.       ((JComponent)var2).setBackground(this.savedBg);
  85.       ((Container)var2).remove(this.message);
  86.       ((Container)var2).remove(this.icon);
  87.       ((Container)var2).remove(this.task);
  88.       if (this.border == ((JComponent)var2).getBorder()) {
  89.          ((JComponent)var2).setBorder((Border)null);
  90.       }
  91.  
  92.       this.message = null;
  93.    }
  94.  
  95.    public void updateIcon(StatusLine var1) {
  96.       this.icon.setIcon(var1.getStatusIcon());
  97.    }
  98.  
  99.    public void updateMessage(StatusLine var1) {
  100.       String var2 = var1.getMessage();
  101.       if (var2 != null && var2.length() != 0) {
  102.          this.message.setText(var2);
  103.       } else {
  104.          this.message.setText(" ");
  105.       }
  106.    }
  107. }
  108.